<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>Campus management platform</title>
	<link rel="stylesheet" href="css/check_box.css">
	<link rel="stylesheet" href="css/index.css" />

	<style>
		.hidden {
			display: none;
		}

		#lang {
			position: fixed;
			right: 0;
			top: 2px;
			cursor: pointer;
		}
	</style>
</head>

<body>
	<a id="lang">中文</a>
	<div id="center">
		<div class="login">
			<div class="title" id="title">Campus management platform</div>

			<div class="user-login">
				<form action="/api/login" method="post" id="form">
					<div class="box">
						<div class="user-title name">username</div>
						<div>
							<input id="user" name="username" />
						</div>
					</div>
					<div class="box">
						<div class="user-title pwd">password</div>
						<div>
							<input id="password" name="password" type="password" />
						</div>
					</div>
					<div class="box">
						<div class="user-title">Verification code</div>
						<div>
							<input style="width: 6rem;" name="code" id="captcha" autocomplete="off" pattern="\d{4}" />
						</div>
						<div>
							<img id="code" style="width: 4rem;height: 2rem;border: 1px solid silver;"
								src="/api/captcha.jpg" alt="Verification code" title="Click me to refresh"
								onclick="this.src='/api/captcha.jpg?'+new Date().getTime()" />
						</div>
					</div>
					<div id="msg"></div>
					<div class="labels">
						<label class="checkbox-inline i-checks">
							<input type="checkbox" name="remember-me" />
							<i></i> Remember password
						</label>
					</div>
					<button>log in</button>
					<div class="box">
						<p>This platform recommends the following browsers:</p>
						<a href="https://www.google.cn/intl/en/chrome/" target="_blank" class="google"
							title="Google Chrome">
							<img src="image/google.png" />
						</a>
						<a href="https://www.mozilla.org/en-US/firefox/new/" target="_blank" class="firefox"
							title="Firefox browser">
							<img src="image/firefox.png" />
						</a>
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="foot">
		<div class="hidden">
			<a href="http://www.hxt5.com">护校通官网</a>
			<a href="https://shop451401809.taobao.com/index.htm?spm=2013.1.w5002-17309633028.2.7b146f57PFRmv3">
				护校通企业店
			</a>
			<a>咨询热线：<span class="phone-number">4000-678-002</span>&nbsp;&nbsp;/&nbsp;&nbsp;<span
					class="phone-number">17875814008</span>&nbsp;&nbsp;(微信同号)</a>
		</div>
		<div class="record-number">
			<a><span class="hidden">广州护校通电子科技有限公司</span>版权所有&copy;2006-2019</a>
			<a class="record-number-right" href="http://www.miit.gov.cn" target="_blank">粤ICP备17102741号-1</a>
		</div>
		<div class="police">
			<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=44011302002266" target="_blank">
				<img src="image/police-icon.png">&nbsp;&nbsp;粤公网安备&nbsp;&nbsp;44011302002266号
			</a>
		</div>
	</div>
	<script>

		fetch('/api/index_url').then(function (res) {
			return res.text();
		}).then(function (text) {
			if (text)
				if (/^\//.test(text)) location.href = text;
				else console.log(text);
		});

		if (/micromessenger/.test(navigator.userAgent.toLowerCase()))
			alert('建议不要在微信中使用本后台系统');

		(function () {
			var dg = document.getElementById.bind(document);
			if (/^.{7}com/.test(document.domain)) {
				dg('user').value = 'a';
				dg('password').value = '1';
				return;
			}

			var s = sessionStorage;
			var bg = 'url(/image/background.png)';

			var q = location.search;
			if (q) {
				q = q.substr(1);

				if (q == 'admin' || s['hxt-r']) {
					bg = 'url(/image/background-admin.png)';
					dg('title').innerText = 'management platform';
					s['hxt-r'] = true;


					var list = document.querySelectorAll('.hidden');
					for (var i = 0; i < list.length; i++) {
						list[i].removeAttribute('class');
					}
				}
				dg('msg').innerText = {
					error: 'User name or password is wrong or account expired',
					code: 'Verification code error!', logout: 'log out successfully！'
				}[q] || '';
			}

			dg('center').style.backgroundImage = bg;

			dg('form').onsubmit = function () {
				s['hxt-u'] = dg('user').value;
				s['hxt-p'] = dg('password').value;
			};

			var u = s['hxt-u'];
			var p = s['hxt-p'];
			if (u) dg('user').value = u;
			if (p) dg('password').value = p;
			s.removeItem('hxt-p');

			dg('lang').onclick = function () {
				fetch('/api/lang/cn').then(function (res) {
					localStorage.lang = 'cn';
					location.replace('/' + location.search);
				});
			};
		})();

	</script>


</body>

</html>